﻿using System.ComponentModel.DataAnnotations;

namespace Dapper.Common
{
    public class PagedRequestBase : IPagedRequest, ISortedRequest
    {
        [Range(10, int.MaxValue)]
        public int PageSize
        {
            get; set;
        }

        [Range(0, int.MaxValue)]
        public int SkipCount
        {
            get
            {
                return (PageIndex - 1) * PageSize;
            }
        }

        [Required]
        [Range(1, int.MaxValue)]
        public int PageIndex
        {
            get; set;
        }

        [Required]
        public string Sorting
        {
            get; set;
        }

        private bool _isDesc = true;

        public bool IsDesc
        {
            get { return _isDesc; }
            set { _isDesc = value; }
        }
    }
}